package com.myth.collectoin;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;

/**
 * jdk5.0 新增了foreach循环，用于遍历集合、数组
 * @author
 * @create 2021/8/16
 */
public class ForeachTest {

    @Test
    public void test1(){
        Collection coll = new ArrayList();
        coll.add(123);
        coll.add(456);
        coll.add(new Person("Jerry",20));
        coll.add(new String("Tom"));
        coll.add(false);

        //for(集合元素的类型局部变量︰集合对象)
        for (Object obj:coll) {
            System.out.println(obj);
        }
    }
}
